The CFileSys class wraps the Microsoft File System Object and provides methods to work with files and folders, giving your application the ability to create, copy, alter, move, and delete files and folders, or to determine if and where particular files or folders exist. It also enables you to get information about files and folders, such as their names and the date they were created or last modified.
Include file: AfxNova/CFileSys.inc
| Name | Description |
|---|---|
| BuildPath | Appends a name to an existing path. |
| CopyFile | Copies one or more files from one location to another. |
| CopyFolder | Recursively copies a folder from one location to another. |
| CreateFolder | Creates a folder. |
| DateTimeToString | Converts a DATE_ type to a string containing the date and the time. |
| DeleteFile | Deletes a specified file. |
| DeleteFolder | Deletes a specified folder and its contents. |
| DriveExists | Checks if the specified drive exists. |
| DriveLetters | Returns a semicolon separated list with the driver letters. |
| FileExists | Checks for the existence of the specified file. |
| FolderExists | Checks for the existence of the specified folder. |
| GetAbsolutePathName | Returns complete and unambiguous path from a provided path specification. |
| GetBaseName | Returns a string containing the base name of the last component, less any file extension, in a path. |
| GetDriveAvailableSpace | Returns the amount of space available to a user on the specified drive or network share. |
| GetDriveFileSystem | Returns the type of file system in use for the specified drive or network share. |
| GetDriveFreeSpace | Returns the amount of free space available to a user on the specified drive or network share. |
| GetDriveName | Returns a string containing the name of the drive for a specified path. |
| GetDriveShareName | Returns the network share name for a specified drive. |
| GetDriveTotalSize | Returns the total space, in bytes, of a drive or network share. |
| GetDriveType | Returns a value indicating the type of a specified drive. |
| GetExtensionName | Returns a string containing the extension name of the file for a specified path. |
| GetFileAttributes | Returns the attributes of files. Read/write or read-only, depending on the attribute. |
| GetFileDateCreated | Returns the date and time that the specified file was created. |
| GetFileDateLastAccessed | Returns the date and time that the specified file was accessed. |
| GetFileDateLastModified | Returns the date and time that the specified file was modified. |
| GetFileName | Returns a string containing the name of the file for a specified path. |
| GetFileShortName | Returns the short name used by programs that require the earlier 8.3 file naming convention. |
| GetFileShortPath | Returns the short path used by programs that require the earlier 8.3 file naming convention. |
| GetFileSize | Returns the size, in bytes, of the specified file. |
| GetFileType | Returns information about the type of a file. |
| GetFileVersion | Returns the version number of a specified file. |
| GetFolderAttributes | Returns the attributes of folders. |
| GetFolderDateCreated | Returns the date and time that the specified folder was created. |
| GetFolderDateLastAccessed | Returns the date and time that the specified folder was last accessed. |
| GetFolderDateLastModified | Returns the date and time that the specified folder was last modified. |
| GetFolderDriveLetter | Returns a string containing the drive letter for a specified folder. |
| GetFolderName | Returns a string containing the name of the folder for a specified path, i.e. the path minus the file name. |
| GetFolderShortName | Returns the short name used by programs that require the earlier 8.3 file naming convention. |
| GetFolderShortPath | Returns the short path used by programs that require the earlier 8.3 file naming convention. |
| GetFolderSize | Returns the size, in bytes, of all files and subfolders contained in the folder. |
| GetFolderType | Returns information about the type of a folder. |
| GetNumDrives | Returns the number of drives. |
| GetNumFiles | Returns the number of files contained in a specified folder, including those with hidden and system file attributes set. |
| GetNumSubFolders | Returns the number of folders contained in a specified folder, including those with hidden and system file attributes set. |
| GetParentFolderName | Returns the folder name for the parent of the specified folder. |
| GetSerialNumber | Returns the decimal serial number used to uniquely identify a disk volume. |
| GetStandardStream | Returns a TextStream object corresponding to the standard input, output, or error stream. |
| GetStdErrStream | Returns a TextStream object corresponding to the standard error stream. |
| GetStdInStream | Returns a TextStream object corresponding to the standard input stream. |
| GetStdOutStream | Returns a TextStream object corresponding to the standard output stream. |
| GetTempName | Returns a randomly generated temporary file or folder name that is useful for performing operations that require a temporary file or folder. |
| GetVolumeName | Returns the volume name of the specified drive. |
| IsDriveReady | Returns True if the specified drive is ready; False if it is not. |
| IsRootFolder | Returns True(-1) if the specified folder is the root folder; False(0) if it is not. |
| MoveFile | Moves one or more files from one location to another. |
| MoveFolder | Moves one or more folders from one location to another. |
| SetFileAttributes | Sets the attributes of files. |
| SetFileName | Sets the name of a specified file. |
| SetFolderAttributes | Sets the attributes of folders. |
| SetFolderName | Sets the name of a specified folder. |
| SetVolumeName | Sets the volume name of the specified drive. |
| Name | Description |
|---|---|
| GetLastResult | Returns the last result code. |
| SetResult | Sets the last result code. |
| GetErrorInfo | Returns a description of the specified error code. |
Returns the last result code.
FUNCTION GetLastResult () AS HRESULT
Sets the result code.
FUNCTION SetResult (BYVAL Result AS HRESULT) AS HRESULT
| Parameter | Description |
|---|---|
| Result | The error code returned by the methods. |
Returns a description of the last result code.
FUNCTION GetErrorInfo () AS DWSTRING
Appends a name to an existing path.
FUNCTION BuildPath (BYREF wszPath AS WSTRING, BYREF wszName AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszPath | Existing path to which name is appended. Path can be absolute or relative and need not specify an existing folder. |
| wszName | Name being appended to the existing path. |
The new path.
The BuildPath method inserts an additional path separator between the existing path and the name, only if necessary.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsNewPath AS DWSTRING = pFileSys.BuildPath("C:\MyFolder", "Text.txt")
' Output: C:\MyFolder\Text.txt
Alternate syntax:
CFileSys().BuildPath("C:\MyFolder", "Text.txt")
Copies one or more files from one location to another.
FUNCTION CopyFile (BYREF wszSource AS WSTRING, BYREF wszDestination AS WSTRING, _
BYVAL OverWriteFiles AS BOOLEAN = TRUE) AS HRESULT
| Name | Description |
|---|---|
| wszSource | Character string file specification, which can include wildcard characters, for one or more files to be copied. |
| wszDestination | Character string destination where the file or files from source are to be copied. Wildcard characters are not allowed. |
| OverWriteFiles | Boolean value that indicates if existing files are to be overwritten. If true, files are overwritten; if false, they are not. The default is true. Note that CopyFile will fail if destination has the read-only attribute set, regardless of the value of overwrite. |
HRESULT. S_OK (0) on success, or an error code on failure.
Wildcard characters can only be used in the last path component of the wszSource argument. For example, you can use:
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.CopyFile("c:\mydocuments\letters\*.doc", "c:\tempfolder\")
But you can’t use:
pFileSys.CopyFile("c:\mydocuments\*\R1???97.xls", "c:\tempfolder")
If wszSource contains wildcard characters, or destination ends with a path separator (“\”), it is assumed that destination is an existing folder in which to copy matching files. Otherwise, destination is assumed to be the name of a file to create. In either case, three things can happen when an individual file is copied:
If destination does not exist, source gets copied. This is the usual case.
If destination is an existing file, an error occurs if overwrite is False. Otherwise, an attempt is made to copy source over the existing file.
If destination is a directory, an error occurs.
An error also occurs if a source using wildcard characters doesn’t match any files. The CopyFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes made before an error occurs.
Files copied to a new destination path will keep the same file name. To rename the copied file, simply include the new file name in the destination path. For example, this will copy the file to a new location and the file in the new location will have a different name:
pFileSys.CopyFile("c:\mydocuments\letters\sample.doc", "c:\tempfolder\sample_new.doc")
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.CopyFile("C:\MyFolder\MyFile.txt", "C:\MyOtherFolder\MyFile.txt")
Alternate syntax:
CFileSys().CopyFile("C:\MyFolder\MyFile.txt", "C:\MyOtherFolder\MyFile.txt")
Recursively copies a folder from one location to another.
FUNCTION CopyFolder (BYREF wszSource AS WSTRING, BYREF wsDestination AS WSTRING, _
BYVAL OverWriteFiles AS BOOLEAN = TRUE) AS HRESULT
| Name | Description |
|---|---|
| wszSource | Character string file specification, which can include wildcard characters, for one or more folders to be copied. |
| wszDestination | Character string destination where the folder and subfolders from source are to be copied (must end with a “\”). Wildcard characters are not allowed. |
| OverWriteFiles | Boolean value that indicates if existing folders are to be overwritten. If true, files are overwritten; if false, they are not. The default is true. |
HRESULT. S_OK (0) on success, or an error code on failure.
Wildcard characters can only be used in the last path component of the wszource argument. For example you can use:
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.CopyFolder "c:\mydocuments\letters\*", "c:\tempfolder\"
But you can’t use:
pFileSys.CopyFolder "c:\mydocuments\*\*", "c:\tempfolder\"
If wszSource contains wildcard characters, or destination ends with a path separator (“\”), it is assumed that destination is an existing folder in which to copy matching folders and subfolders. Otherwise, destination is assumed to be the name of a folder to create. In either case, four things can happen when an individual folder is copied:
If destination does not exist, the source folder and all its contents gets copied. This is the usual case.
If destination is an existing file, an error occurs.
If destination is a directory, an attempt is made to copy the folder and all its contents. If a file contained in source already exists in destination, an error occurs if overwrite is False. Otherwise, it will attempt to copy the file over the existing file.
If destination is a read-only directory, an error occurs if an attempt is made to copy an existing read-only file into that directory and OverWriteFiles is False.
An error also occurs if a source using wildcard characters doesn’t match any folders.
The CopyFolder method stops on the first error it encounters. No attempt is made to roll back any changes made before an error occurs.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.CopyFolder("C:\MyFolder", "C:\MyOtherFolder\")
Creates a folder.
FUNCTION CreateFolder (BYREF wszFolderSpec AS WSTRING) AS Afx_IFolder PTR
| Name | Description |
|---|---|
| wszFolderSpec | String expression that identifies the folder to create. |
IDispatch. Reference to an IFolder object.
An error occurs if the specified folder already exists.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM pFolder AS Afx_IFolder PTR
pFolder = pFileSys.CreateFolder("C:\MyNewFolder")
IF pFolder THEN
' ....
pFolder->Release
END IF
Deletes a specified file.
FUNCTION DeleteFile (BYREF wszFileSpec AS WSTRING, BYVAL bForce AS BOOLEAN = FALSE) AS HRESULT
| Name | Description |
|---|---|
| wszFileSpec | The name of the file to delete. cbsFileSpec can contain wildcard characters in the last path component. |
| bForce | Boolean value that is true if files with the read-only attribute set are to be deleted; false (default) if they are not. |
HRESULT. S_OK (0) on success, or an error code on failure.
An error occurs if no matching files are found. The DeleteFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes that were made before an error occurred.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.DeleteFile("C:\MyFolder\MyFile.txt")
Deletes a specified folder and its contents.
FUNCTION DeleteFolder (BYREF wszFolderSpec AS WSTRING, BYVAL bForce AS BOOLEAN = FALSE) AS HRESULT
| Name | Description |
|---|---|
| wszFolderSpec | The name of the folder to delete. wszFolderSpec can contain wildcard characters in the last path component. |
| bForce | Boolean value that is true if folders with the read-only attribute set are to be deleted; false (default) if they are not. |
HRESULT. S_OK (0) on success, or an error code on failure.
The DeleteFolder method does not distinguish between folders that have contents and those that do not. The specified folder is deleted regardless of whether or not it has contents.
An error occurs if no matching folders are found. The DeleteFolder method stops on the first error it encounters. No attempt is made to roll back or undo any changes that were made before an error occurred.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.DeleteFolder("C:\MyFolder")
Returns True if the specified drive exists; False if it does not.
FUNCTION DriveExists (BYREF wszDriveSpec AS WSTRING) AS BOOLEAN
| Name | Description |
|---|---|
| wszDriveSpec | A drive letter or a complete path specification. |
BOOLEAN. True if the specified drive exists; False if it does not.
For drives with removable media, the DriveExists method returns true even if there are no media present. Use the IsDriveReady method to determine if a drive is ready.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM fExists AS BOOLEAN = pFileSys.DriveExists("C:")
Returns a semicolon separated list with the driver letters.
FUNCTION DriveLetters () AS DWSTRING
A semicolon separated list with the driver letters.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsLetters AS DWSTRING = pFileSys.DriveLetters
Returns True if the specified file exists; False if it does not.
FUNCTION FileExists (BYREF wszFileSpec AS WSTRING) AS BOOLEAN
| Name | Description |
|---|---|
| wszFileSpec | CBSTR. The name of the file whose existence is to be determined. A complete path specification (either absolute or relative) must be provided if the file isn’t expected to exist in the current folder. |
Boolean. True if the specified file exists; False if it does not.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM fExists AS BOOLEAN = pFileSys.FileExists("C:\MyFolder\Test.txt")
Returns True if the specified folder exists; False if it does not.
FUNCTION FolderExists (BYREF wszFolderSpec AS WSTRING) AS BOOLEAN
| Name | Description |
|---|---|
| wszFolderSpec | CBSTR. The name of the folder whose existence is to be determined. A complete path specification (either absolute or relative) must be provided if the folder isn’t expected to exist in the current folder. |
Boolean. True if the specified folder exists; False if it does not.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM fExists AS BOOLEAN = pFileSys.FolderExists("C:\MyFolder")
Returns complete and unambiguous path from a provided path specification.
FUNCTION GetAbsolutePathName (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszPathSpec | Path specification to change to a complete and unambiguous path. |
Boolean. The path name.
A path is complete and unambiguous if it provides a complete reference from the root of the specified drive. A complete path can only end with a path separator character (“\”) if it specifies the root folder of a mapped drive.
Assuming the current directory is c:, the following table illustrates the behavior of the GetAbsolutePathName method.
| pathspec | Returned path |
|---|---|
| “c:” | “c:” |
| “c:..” | “c:” |
| “c:" | “c:" |
| “c:.” | “c:\*.*” |
| “region1” | “c:” |
| “c:....” | “c:” |
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM cbsName AS CBSTR = pFileSys.GetAbsolutePathName("C:\MyFolder\Test.txt")
Returns a string containing the base name of the last component, less any file extension, in a path
FUNCTION GetBaseName (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszPathSpec | The path specification for the component whose base name is to be returned. |
Boolean. The base name.
The GetBaseName method returns a zero-length string (““) if no component matches the path argument. The GetBaseName method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM cwsName AS CWSTR = pFileSys.GetBaseName("C:\MyFolder\Test.txt")
Returns the amount of space available to a user on the specified drive or network share.
FUNCTION GetDriveAvailableSpace (BYREF wszDrive AS WSTRING) AS DOUBLE
| Name | Description |
|---|---|
| wszDrive | The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
DOUBLE. The amount of available space.
The value returned by the GetDriveAvailableSpace method is typically the same as that returned by the GetDriveFreeSpace method. Differences may occur between the two for computer systems that support quotas.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
PRINT pFileSys.GetDriveAvailableSpace("C:")
Returns the type of file system in use for the specified drive or network share.
FUNCTION GetDriveFileSystem (BYREF wszDrive AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszDrive | CBSTR. The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
The type of file system in use.
Available return types include FAT, NTFS, and CDFS.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsFileSystem AS DWSTRING = pFileSys.GetDriveFileSystem("C:")
Returns the amount of free space available to a user on the specified drive or network share
FUNCTION GetDriveFreeSpace (BYREF wszDrive AS WSTRING) AS DOUBLE
| Name | Description |
|---|---|
| wszDrive | CBSTR. The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
DOUBLE. The amount of free space.
The value returned by the GetDriveFreeSpace property is typically the same as that returned by the GetDriveAvailableSpace property. Differences may occur between the two for computer systems that support quotas.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
PRINT pFileSys.GetDriveFreeSpace("C:")
Returns a string containing the name of the drive for a specified path.
FUNCTION GetDriveName (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszPathSpec | CBSTR. The path. |
The drive name.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsName AS DWSTRING = pFileSys.GetDriveName("C:\MyFolder\Test.txt")
Returns the network share name for a specified drive.
FUNCTION GetDriveShareName (BYREF wszDrive AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszDrive | The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
The share name.
If object is not a network drive, the GetDriveShareName method returns a zero-length string (““).
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsShareName AS DWSTRING = pFileSys.GetDriveShareName("H:")
Returns the total space, in bytes, of a drive or network share.
FUNCTION GetDriveTotalSize (BYREF wszDrive AS WSTRING) AS DOUBLE
| Name | Description |
|---|---|
| wszDrive | CBSTR. The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
DOUBLE. The total space in bytes.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
PRINT pFileSys.GetDriveTotalSize("C:")
Returns a value indicating the type of a specified drive.
FUNCTION GetDriveType (BYREF wszDrive AS WSTRING) AS DRIVETYPECONST
| Name | Description |
|---|---|
| wszDrive | CBSTR. The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
The type of the specified drive.
DriveType_UnknownType = 0
DriveType_Removable = 1
DriveType_Fixed = 2
DriveType_Remote = 3
DriveType_CDRom = 4
DriveType_RamDisk = 5
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nDriveType AS DRIVETYPECONST = pFileSys.GetDriveType("C:")
DIM t AS DWSTRING
SELECT CASE pDrive.DriveType
CASE 0 : t = "Unknown"
CASE 1 : t = "Removable"
CASE 2 : t = "Fixed"
CASE 3 : t = "Network"
CASE 4 : t = "CD-ROM"
CASE 5 : t = "RAM Disk"
END SELECT
Returns a string containing the extension name of the file for a specified path.
FUNCTION GetExtensionName (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszPathSpec | The extension name. |
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsName AS DWSTRING = pFileSys.GetExtensionName("C:\MyFolder\Test.txt")
Returns the attributes of files.
FUNCTION GetFileAttributes (BYREF wszFile AS WSTRING) AS FILEATTRIBUTE
| Name | Description |
|---|---|
| wszFile | The path to a specific file. |
The file attributes. Can be any of the following values or any logical combination of the following values:
| Constant | Value | Description |
|---|---|---|
| FileAttribute_Normal | 0 | Normal file. No attributes are set. |
| FileAttribute_ReadOnly | 1 | Read-only file. Attribute is read/write. |
| FileAttribute_Hidden | 2 | Hidden file. Attribute is read/write. |
| FileAttribute_System | 4 | System file. Attribute is read/write. |
| FileAttribute_Volume | 8 | Disk drive volume label. Attribute is read-only. |
| FileAttribute_Directory | 16 | Folder or directory. Attribute is read-only. |
| FileAttribute_Archive | 32 | File has changed since last backup. Attribute is read/write. |
| FileAttribute_Alias | 1024 | Link or shortcut. Attribute is read-only. |
| FileAttribute_Compressed | 2048 | Compressed file. Attribute is read-only. |
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM lAttr FILEATTRIBUTE = pFileSys.GetFileAttributes("C:\MyPath\MyFile.txt")
Returns the date and time that the specified file was created.
FUNCTION GetFileDateCreated (BYREF wszFile AS WSTRING) AS DATE_
| Name | Description |
|---|---|
| wszFile | The path to a specific file. |
DATE_. The date and time of the file creation. This is a Date Serial number that can be formatted using the Free Basic’s Format function. You can also use the wrapper function AfxVariantDateTimeToStr.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nDate AS DATE_ = pFileSys.GetFileDateCreated("C:\MyPath\MyFile.txt")
Returns the date and time that the specified file was accesed.
FUNCTION GetFileDateLastAccessed (BYREF wszFile AS WSTRING) AS DATE_
| Name | Description |
|---|---|
| wszFile | The path to a specific file. |
DATE_. The date and time that the file was last accessed. This is a Date Serial number that can be formatted using the Free Basic’s Format function. You can also use the wrapper function AfxVariantDateTimeToStr.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nDate AS DATE_ = pFileSys.GetFileDateLastAccessed("C:\MyPath\MyFile.txt")
Returns the date and time that the specified file was accessed.
FUNCTION GetFileDateLastModified (BYREF wszFile AS WSTRING) AS DATE_
| Name | Description |
|---|---|
| wszFile | The path to a specific file. |
DATE_. The date and time that the file was last modified. This is a Date Serial number that can be formatted using the DateTimeToString method or the Free Basic’s Format function.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nDate AS DATE_ = pFileSys.GetFileDateLastModified("C:\MyPath\MyFile.txt")
PRINT pFilesys.DateTimeToString(nDate)
Returns a string containing the name of the file for a specified path.
FUNCTION GetFileName (BYREF wszPathSpec AS WSTRING) AS DWSREING
| Name | Description |
|---|---|
| wszPathSpec | The path to a specific file. |
The file name.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsName AS DWSTRING = pFileSys.GetFileName("C:\MyFolder\Test.txt")
Returns the short name used by programs that require the earlier 8.3 file naming convention.
FUNCTION GetFileShortName (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszPathSpec | The path to a specific file. |
The short name for the specified file.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsName AS DWSTRING = pFileSys.GetFileShortName("C:\MyFolder\Test.txt")
Returns the short path used by programs that require the earlier 8.3 file naming convention.
FUNCTION GetFileShortPath (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszPathSpec | The path to a specific file. |
The short path to a specific file.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsName AS DWSTRING = pFileSys.GetFileShortPath("C:\MyFolder\Test.txt")
Returns the size, in bytes, of the specified file.
FUNCTION GetFileSize (BYREF wszFile AS WSTRING) AS LONG
| Name | Description |
|---|---|
| wszFile | The path to a specific file. |
LONG. The size, in bytes, of the file.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nFileSize AS LONG = pFileSys.GetFileSize("C:\MyPath\MyFile.txt")
Returns localized information about the type of a file. For example, for files ending in .TXT, “Text Document” is returned (“Documento de texto” in Spanish computers).
FUNCTION GetFileType (BYREF wszFile AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszFile | The path to a specific file. |
The type of file.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsFileType AS DWSTRING = pFileSys.GetFileType("C:\MyPath\MyFile.txt")
Returns the version number of a specified file.
FUNCTION GetFileVersion (BYREF dwsFile AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszFile | The path (absolute or relative) to a specific file. |
The version number.
The GetFileVersion method returns a zero-length string (““) if wszFile does not end with the named component.
Note: The GetFileVersion method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsVersion AS DWSTRING = pFileSys.GetFileVersion("C:\MyFolder\MyFile.doc")
IF LEN(dwsVersion) THEN
MSGBOX "File version: " & dwsVersion
ELSE
MSGBOX "No version information available"
END IF
DIM pFileSys AS CFileSys
print pFileSys.GetFileVersion("c:\windows\system32\scrrun.dll")
Returns the attributes of folders.
FUNCTION GetFolderAttributes (BYREF wszFolder AS WSTRING) AS FILEATTRIBUTE
| Name | Description |
|---|---|
| wszFolder | CBSTR. The path to a specific folder. |
The attributes. Can be any of the following values or any logical combination of the following values:
| Constant | Value | Description |
|---|---|---|
| FileAttribute_Normal | 0 | Normal file. No attributes are set. |
| FileAttribute_ReadOnly | 1 | Read-only file. Attribute is read/write. |
| FileAttribute_Hidden | 2 | Hidden file. Attribute is read/write. |
| FileAttribute_System | 4 | System file. Attribute is read/write. |
| FileAttribute_Volume | 8 | Disk drive volume label. Attribute is read-only. |
| FileAttribute_Directory | 16 | Folder or directory. Attribute is read-only. |
| FileAttribute_Archive | 32 | File has changed since last backup. Attribute is read/write. |
| FileAttribute_Alias | 1024 | Link or shortcut. Attribute is read-only. |
| FileAttribute_Compressed | 2048 | Compressed file. Attribute is read-only. |
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM lAttr FILEATTRIBUTE = pFileSys.GetFolderAttributes("C:\MyPath")
Returns the date and time that the specified folder was created.
FUNCTION GetFolderDateCreated (BYREF wszFolder AS WSTRING) AS DATE_
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
DATE_. The date and time that the folder was created. This is a Date Serial number that can be formatted using The DateTimeoStringmethod pr the Free Basic’s Format function.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nDate AS DATE_ = pFileSys.GetFolderDateCreated("C:\MyPath")
PRINT pFilesys.DateTimeToString(nDate)
Returns the date and time that the specified folder was last accessed.
FUNCTION GetFolderDateLastAccessed (BYREF dwsFolder AS WSTRING) AS DATE_
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
DATE_. The date and time that the folder was last accessed. This is a Date Serial number that can be formatted using the DateTimeToString method or the Free Basic’s Format function.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nDate AS DATE_ = pFileSys.GetFolderDateLastAccessed("C:\MyPath)
PRINT pFilesys.DateTimeToString(nDate)
Returns the date and time that the specified folder was last modified.
FUNCTION GetFolderDateLastModified (BYREF wszFolder AS WSTRING) AS DATE_
| Name | Description |
|---|---|
| wszFolder | CBSTR. The path to a specific folder. |
DATE_. The date and time that the folder was last modified. This is a Date Serial number that can be formatted using the DateTimeToString method or the Free Basic’s Format function.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nDate AS DATE_ = pFileSys.GetFolderDateLastModified("C:\MyPath)
PRINT pFilesys.DateTimeToString(nDate
Returns a string containing the drive letter for a specified folder.
FUNCTION GetFolderDriveLetter (BYREF wszFolder AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
The drive letter of the folder.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsDriveLetter AS DWSTRING = pFileSys.GetFolderDriveLetter("c:\MyFolder)
Returns a string containing the name of the folder for a specified path, i.e. the path minus the file name.
FUNCTION GetFolderName (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
The name of the folder.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsName AS DWSTRING = pFileSys.GetFolderName("C:\MyFolder\Test.txt")
Returns the short name used by programs that require the earlier 8.3 file naming convention.
FUNCTION GetFolderShortName (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
The short name for the specified folder.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsFolderShorName AS DWSTRING = pFileSys.GetFolderShortName("c:\MyFolder)
Returns the short path used by programs that require the earlier 8.3 file naming convention.
FUNCTION GetFolderShortPath (BYREF wszPathSpec AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
The short path for the specified folder.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsFolderShortPath AS DWSTRING = pFileSys.GetFolderShortPath("c:\MyFolder)
Returns the size, in bytes, of all files and subfolders contained in the folder.
FUNCTION GetFolderSize (BYREF wszFolder AS WsTRING) AS LONG
| Name | Description |
|---|---|
| wszFolder | CBSTR. The path to a specific folder. |
LONG. The size, in bytes, of all files and subfolders contained in the folder.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nFolderSize AS LONG = pFileSys.GetFolderSize("C:\MyPath")
Returns information about the type of a folder.
FUNCTION GetFolderType (BYREF wszFolder AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszFolder | CBSTR. The path to a specific folder. |
CBSTR. The type of folder.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsFolderType AS DWSTRING = pFileSys.GetFolderType("c:\MyFolder)
Returns the number of drives.
FUNCTION GetNumDrives () AS LONG
LONG. The number of drives.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM numDrives AS LONG = pFileSys.GetNumDrives
Returns the number of files contained in a specified folder, including those with hidden and system file attributes set.
FUNCTION GetNumFiles (BYREF wszFolder AS WSTRING) AS LONG
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
LONG. The number of files.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM numFiles AS LONG = pFileSys.GetNumFiles("C:\MyFolder")
Returns the number of files contained in a specified folder, including those with hidden and system file attributes set.
FUNCTION GetNumSubFolders (BYREF wszFolder AS WsTRING) AS LONG
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
LONG. The number of subfolders.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM numSubFolders AS LONG = pFileSys.GetNumSubFolders("C:\MyFolder")
Returns the folder name for the parent of the specified folder.
FUNCTION GetParentFolderName (BYREF wszFolder AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
The name of the parent folder, or a empty string if the folder has no parent.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsParentFolderName AS DWsTRING = pFileSys.GetParentFolderName("C:\MyFolder\MySubfolder")
Returns the decimal serial number used to uniquely identify a disk volume.
FUNCTION GetSerialNumber (BYREF wszDrive AS WSTRING) AS LONG
| Name | Description |
|---|---|
| wszDrive | CBSTR. The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
LONG. The serial number.
You can use the GetSerialNumber method to ensure that the correct disk is inserted in a drive with removable media.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM nSerialNumber AS LONG = pFileSys.GetSerialNumber("C:")
Returns a TextStream object corresponding to the standard input, output, or error stream.
FUNCTION GetStandardStream (BYVAL nStreamType AS STANDARDSTREAMTYPES, _
BYVAL bUnicode AS BOOLEAN = FALSE) AS Afx_ITextStream PTR
| Name | Description |
|---|---|
| nStreamType | LONG. Can be one of three constants: StandardStreamTypes_StdErr, StandardStreamTypes_StdIn, or StandardStreamTypes_StdOut. |
| bUnicode | Boolean value that indicates whether the file is created as a Unicode or ASCII file. The value is true if the file is created as a Unicode file, false if it is created as an ASCII file. If omitted, an ASCII file is assumed. |
A pointer to the ITextStream interface of the requested standard stream.
The nStreamType argument can have any of the following settings:
| Constant | Constant | Description |
|---|---|---|
| StandardStreamTypes_StdIn | 0 | Returns a TextStream object corresponding to the standard input stream. |
| StandardStreamTypes_StdOut | 1 | Returns a TextStream object corresponding to the standard output stream. |
| StandardStreamTypes_StdErr | 2 | Returns a TextStream object corresponding to the standard error stream. |
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM pStm AS Afx_ITextStream PTR = pFileSys.GetStandardStream(StandardStreamTypes_StdOut)
Returns a TextStream object corresponding to the standard error stream.
FUNCTION GetStdErrStream (BYVAL bUnicode AS BOOLEAN = FALSE) AS Afx_ITextStream PTR
| Name | Description |
|---|---|
| bUnicode | Boolean value that indicates whether the file is created as a Unicode or ASCII file. The value is true if the file is created as a Unicode file, false if it is created as an ASCII file. If omitted, an ASCII file is assumed. |
A pointer to the ITextStream interface of the standard error stream.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM pStm AS Afx_ITextStream PTR = pFileSys.GetStdErrStream
Returns a TextStream object corresponding to the standard input stream.
FUNCTION GetStdInStream (BYVAL bUnicode AS BOOLEAN = FALSE) AS Afx_ITextStream PTR
| Name | Description |
|---|---|
| bUnicode | Boolean value that indicates whether the file is created as a Unicode or ASCII file. The value is true if the file is created as a Unicode file, false if it is created as an ASCII file. If omitted, an ASCII file is assumed. |
A pointer to the ITextStream interface of the standard input stream.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM pStm AS Afx_ITextStream PTR = pFileSys.GetStdInStream
Returns a TextStream object corresponding to the standard output stream.
FUNCTION GetStdOutStream (BYVAL bUnicode AS BOOLEAN = FALSE) AS Afx_ITextStream PTR
| Name | Description |
|---|---|
| bUnicode | Boolean value that indicates whether the file is created as a Unicode or ASCII file. The value is true if the file is created as a Unicode file, false if it is created as an ASCII file. If omitted, an ASCII file is assumed. |
A pointer to the ITextStream interface of the standard output stream.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM pStm AS Afx_ITextStream PTR = pFileSys.GetStdOutStream
Returns a randomly generated temporary file or folder name that is useful for performing operations that require a temporary file or folder.
FUNCTION GetTempName () AS DWSTRING
The temporary name.
The GetTempName method does not create a file. It provides only a temporary file name that can be used with CreateTextFile to create a file.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM cbsName AS CBSTR = pFileSys.GetTempName
Returns the volume name of the specified drive.
FUNCTION GetVolumeName (BYREF dwsDrive AS WSTRING) AS DWSTRING
| Name | Description |
|---|---|
| dwsDrive | CBSTR. The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
The volume name.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM dwsVolumeName AS DWSTRING = pFileSys.GetVolumeName("C:")
Returns True if the specified drive is ready; False if it is not.
FUNCTION IsDriveReady (BYREF dwsDrive AS STRING) AS BOOLEAN
| Name | Description |
|---|---|
| wszDrive | CBSTR. The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
BOOLEAN. True if the specified drive is ready; False if it is not.
For removable-media drives and CD-ROM drives, IsDriveReady returns True only when the appropriate media is inserted and ready for access.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM bIsReady AS BOOLEAN = pFileSys.IsDriveReady("C:")
Returns True(-1) if the specified folder is the root folder; False(0) if it is not.
FUNCTION IsRootFolder (BYREF dwsFolder AS WSTRIN) AS BOOLEAN
| Name | Description |
|---|---|
| wszDrive | CBSTR. The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
BOOLEAN. True(-1) if the specified folder is the root folder; False(0) if it is not.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
DIM bIsRoot AS BOOLEAN = pFileSys.IsRootFolder("C:\MyFolder")
Moves one or more files from one location to another.
FUNCTION MoveFile (BYREF wszSource AS DWSTRING, BYREF wszDestination AS WSTRING) AS HRESULT
| Name | Description |
|---|---|
| cwszource | The path to the file or files to be moved. The wszSource argument string can contain wildcard characters in the last path component only. |
| wszDestination | Destination where the file is to be moved. Wildcard characters are not allowed. |
HRESULT. S_OK (0) on success, or an error code on failure.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.MoveFile("C:\MyFolder\MyFile.txt", "C:\MyOtherFolder\")
Moves one or more folders from one location to another.
FUNCTION MoveFolder (BYREF wszSource AS WSTRING, BYREF wszDestination AS WSTRING) AS HRESULT
| Name | Description |
|---|---|
| wszSource | CBSTR. The path to the folder or folders to be moved. The cbsSource argument string can contain wildcard characters in the last path component only. |
| wszDestination | CBSTR. Destination where the folder is to be moved (must end with a “\”). Wildcard characters are not allowed. |
HRESULT. S_OK (0) on success, or an error code on failure.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.MoveFolder("C:\MyFolder", "C:\MyNewFolder\")
Sets the attributes of files.
FUNCTION SetFileAttributes (BYREF wszFile AS WSTRING, BYVAL lAttr AS FILEATTRIBUTE) AS HRESULT
| Name | Description |
|---|---|
| wszFile | The path to a specific file. |
| lAttr | LONG. The new value for the attributes of the specified file. |
The file attributes. Can be any of the following values or any logical combination of the following values:
| Constant | Value | Description |
|---|---|---|
| FileAttribute_Normal | 0 | Normal file. No attributes are set. |
| FileAttribute_ReadOnly | 1 | Read-only file. Attribute is read/write. |
| FileAttribute_Hidden | 2 | Hidden file. Attribute is read/write. |
| FileAttribute_System | 4 | System file. Attribute is read/write. |
| FileAttribute_Volume | 8 | Disk drive volume label. Attribute is read-only. |
| FileAttribute_Directory | 16 | Folder or directory. Attribute is read-only. |
| FileAttribute_Archive | 32 | File has changed since last backup. Attribute is read/write. |
| FileAttribute_Alias | 1024 | Link or shortcut. Attribute is read-only. |
| FileAttribute_Compressed | 2048 | Compressed file. Attribute is read-only. |
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.SetFileAttributes("C:\MyPath\MyFile.txt", 33) ' FileAttribute_Archive OR FileAttribute_Normal
Sets the name of a specified file.
FUNCTION SetFileName (BYREF wszFile AS WSTRING, BYREF wszName AS WSTRING) AS HRESULT
| Name | Description |
|---|---|
| wszFile | CBSTR. The path to a specific file. |
| wszName | CBSTR. The new name of the file. |
HRESULT. S_OK (0) on success, or an error code on failure.
You only have to pass the new name of the file, not the full path.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.SetFileName("c:\MyFolder\Test.txt", "NewName")
Sets the attributes of folders.
FUNCTION SetFolderAttributes (BYREF wszFolder AS WSTRING, BYVAL lAttr AS FILEATTRIBUTE) AS HRESULT
| Name | Description |
|---|---|
| wszFolder | CBSTR. The path to a specific folder. |
| lAttr | LONG. The new value for the attributes of the specified folder. |
The lAttr argument can have any of the following values or any logical combination of the following values:
| Constant | Value | Description |
|---|---|---|
| FileAttribute_Normal | 0 | Normal file. No attributes are set. |
| FileAttribute_ReadOnly | 1 | Read-only file. Attribute is read/write. |
| FileAttribute_Hidden | 2 | Hidden file. Attribute is read/write. |
| FileAttribute_System | 4 | System file. Attribute is read/write. |
| FileAttribute_Volume | 8 | Disk drive volume label. Attribute is read-only. |
| FileAttribute_Directory | 16 | Folder or directory. Attribute is read-only. |
| FileAttribute_Archive | 32 | File has changed since last backup. Attribute is read/write. |
| FileAttribute_Alias | 1024 | Link or shortcut. Attribute is read-only. |
| FileAttribute_Compressed | 2048 | Compressed file. Attribute is read-only. |
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.SetFolderAttributes("C:\MyPath\MyFile.txt", 17) ' FileAttribute_Directory OR FileAttribute_ReadOnly
Sets the name of a specified folder.
FUNCTION SetFolderName (BYREF wszFolder AS WSTRING, BYREF wszName AS WSTRING) AS HRESULT
| Name | Description |
|---|---|
| wszFolder | The path to a specific folder. |
| wszName | The new name of the folder. |
HRESULT. S_OK (0) on success, or an error code on failure.
You only have to pass the new name of the folder, not the full path.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.SetFolderName("c:\MyFolder", "NewName")
Sets the name of a specified drive.
FUNCTION SetVolumeName (BYREF wszDrive AS WSTRING, BYREF wszName AS WSTRING) AS HRESULT
| Name | Description |
|---|---|
| wszDrive | The drive letter. For drive letters, the root drive is not included. For example, the path for the C drive is C:, not C:\. |
| wszName | The volume name. |
HRESULT. S_OK (0) on success, or an error code on failure.
#INCLUDE ONCE "AfxNova/CFileSys.inc"
DIM pFileSys AS CFileSys
pFileSys.SetVolumeName("C:", "VolumeName")
Converts a DATE_ type to a string containing the date and the time.
FUNCTION DateTimeToString (BYVAL vbDate AS DATE_, BYVAL lcid AS LCID = LOCALE_USER_DEFAULT, _
BYVAL dwFlags AS DWORD = 0) AS DWSTRING
| Parameter | Description |
|---|---|
| vbDate | A variant representation of time. |
| lcid | Optional. The language identifier used for the conversion. Default is LOCALE_USER_DEFAULT. |
| dwFlags | Optional. A value made from one or more flags. The following table shows the flags that can be set for this parameter. |
| Flag | Description |
|---|---|
| LOCALE_NOUSEROVERRIDE | Uses the system default locale settings, rather than custom locale settings. |
| VAR_CALENDAR_HJRI | If set then the Hijri calendar is used. Otherwise the calendar sent in Control Panel is used. |
| VAR_DATEVALUEONLY | Omits the time portion of a VT_DATE and retrieves
only the date. Applies to conversions to or from dates. Not used for ChangeType and ChangeTypeEx. |
| VAR_TIMEVALUEONLY | Omits the date portion of a VT_DATE and returns only the time. Applies to conversions to or from dates. Not used for ChangeType and ChangeTypeEx. |
The formatted date and time.